#include "gofgame/dungeonkeeper/loadingscene/LoadingLayer.h"
#include "gofgame/dungeonkeeper/game/LevelScene.h"
#include "gofgame/dungeonkeeper/game/GameManager.h"

using namespace gofgame::dungeonkeeper::loadingscene;

bool LoadingLayer::init(){
	bool bRet = false;
	do 
	{
		CC_BREAK_IF(!CCLayer::init());
		CCSize winSize = CCDirector::sharedDirector()->getWinSize();
		//BG

		CCSprite * bg = CCSprite::create("loadingBg.jpg");
		bg->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.5));
		this->addChild(bg);
		this->scheduleOnce(schedule_selector(LoadingLayer::goLoading),0.0f);
		bRet = true;
	} while (0);
	return bRet;
}


void LoadingLayer::goLoading(float dt){
	std::string levelName = GameManager::sharedGameManager()->currentLevel;
	LevelScene *ls = LevelScene::createWithLevel(const_cast<char *>(levelName.c_str()));
	CCDirector::sharedDirector()->replaceScene(ls);
}